﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using CheckLift.ViewModels;
using CheckLift.Linq;
using CheckLift.Common.Intf;

namespace CheckLift.Views
{
    /// <summary>
    /// Interaction logic for ReportDetailView.xaml
    /// </summary>
    public partial class ReportDetailView : Window
    {
        private ReportDetailsViewModel reportDetailsViewModel;

        public ReportDetailView()
        {
            InitializeComponent();            
        }

        public void InitDataContext(User user, IReport reportView)
        {
            reportDetailsViewModel = new ReportDetailsViewModel();
            reportDetailsViewModel.InitReportData(user, reportView);
            DataContext = reportDetailsViewModel.ReportDetailView;
            reportDetailViewControl1.DataContext = reportDetailsViewModel.ReportDetailView;
        }

        private void CommandBinding_CanExecute(object sender, CanExecuteRoutedEventArgs e)
        {
            if (e.Parameter != null)
            {
                switch (e.Parameter.ToString())
                {
                    case "Save":
                        break;
                    default:
                        break;
                }
            }
       
        }

        private void CommandBinding_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            if (e.Parameter != null)
            {
                switch (e.Parameter.ToString())
                {
                    case "Save":
                        reportDetailsViewModel.SaveReportDetails();
                        this.Close();
                        break;
                    case "Close":
                        this.Close();
                        break;
                    default:
                        break;
                }
            }
           
        }
    }
}
